//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Drawing;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class InnerShadowEffect : Effect
    {
        private int blurRad;
        private int dir;

        private int dist;

        public int Direction
        {
            get { return dir; }
            set { dir = value; }
        }

        public int Distance
        {
            get { return dist; }
            set { dist = value; }
        }


        public int BlurRadius
        {
            get { return blurRad; }
            set { blurRad = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("innerShdw"))
            {
                BlurRadius = c.GetOptionalInteger("blurRad", 0);
                Distance = c.GetOptionalInteger("dist", 0);
                Direction = c.GetOptionalInteger("dir", 0);
                this.Color = ColorBase.ReadColor(c);
            }
        }

        protected ColorBase Color { get; set; }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("innerShdw"))
            {
                c.SetOptionalInteger("blurRad", BlurRadius, 0);
                c.SetOptionalInteger("dist", Distance, 0);
                c.SetOptionalInteger("dir", Direction, 0);
                c.WriteElement(Color);
            }
        }
    }
}